package genealogy.deprecated.datamodel.pedigree;

import genealogy.deprecated.datamodel.pedigree.visitors.IPedigreeVisitor;

import java.io.Serializable;

/**
 * 
 * @author Steve
 */
@Deprecated
public class Name implements Serializable, IPedigreeVisitable{

	private static final long serialVersionUID = -4267817271592209161L;

	private String m_name;

	/**
	 * Constructor
	 * @param name Space delimited, in the following order: FirstName space middleName1 space ... lastName
	 */
	public Name(String name) {
		super();
		assert(!name.contains(","));
		m_name = name.trim();
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return m_name;
	}
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString(){
		return m_name;
	}

	/* (non-Javadoc)
	 * @see genealogy.datamodel.pedigree.IPedigreeVisitable#accept(genealogy.datamodel.pedigree.visitors.AbstractPedigreeVisitor)
	 */
	public void accept(IPedigreeVisitor visitor) {
		visitor.visit(this);
		visitor.endVisit();
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Name){
			Name n = (Name) obj;
			return m_name.equalsIgnoreCase(n.m_name);
		}
		return false;
	}
}
